package com.meisupic.copyright.controller;

import static com.meisupic.copyright.common.Constants.CERTIFICATES_DIR;
import static com.meisupic.copyright.common.Constants.WORKS_DIR;

import com.meisupic.copyright.domain.vo.OssPostPolicyVo;
import com.meisupic.copyright.service.IOssService;
import com.meisupic.copyright.support.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lanjian
 * @version V1.0
 * @Description: TODO
 * @date 2018/1/28 14:16
 */
@RestController
@RequestMapping("oss")
public class OssController {

  @Autowired
  private IOssService ossService;

  @GetMapping("getCertPolicy")
  public Message getCertPolicy() {
    OssPostPolicyVo ossPostPolicyVo = ossService.getPostPolicy(CERTIFICATES_DIR);
    return Message.success(ossPostPolicyVo);
  }

  @GetMapping("getWorksPolicy")
  public Message getWorksPolicy() {
    OssPostPolicyVo ossPostPolicyVo = ossService.getPostPolicy(WORKS_DIR);
    return Message.success(ossPostPolicyVo);
  }


  @GetMapping("deleteObject")
  public Message deleteObject(String key){
    ossService.deleteObject(key);
    return Message.success(true);
  }

  @GetMapping("genThumb")
  public Message genThumb(String key){
    return Message.success(true);
  }

}
